package com.ehome.poct.backend.controller.device;

import com.ehome.core.page.Page;
import com.ehome.poct.base.api.dto.device.*;
import com.ehome.poct.base.api.feign.device.TestDeviceVersionFeginClient;
import com.ehome.poct.base.api.qry.TestDeviceVersionQry;
import com.ehome.poct.base.api.vo.device.TestDeviceVersionSelVO;
import com.ehome.poct.base.api.vo.device.TestDeviceVersionVO;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 版本表控制器
 *
 * @author yjm
 * @Date 2021-12-09 10:25
 */
@Slf4j
@Api(tags = "版本表")
@RestController
@RequestMapping("/test_device_version")
public class TestDeviceVersionController {
    @Autowired
    private TestDeviceVersionFeginClient testDeviceVersionFeginClient;
    
    @ApiOperation("新增版本")
    @ApiOperationSupport(author = "瑶苏", order = 1)
    @PostMapping
    public void insert(@RequestBody @Valid TestDeviceVersionAddDTO dto) {
        testDeviceVersionFeginClient.insert(dto);
    }
    
    @ApiOperation("修改版本")
    @ApiOperationSupport(author = "瑶苏", order = 2)
    @PutMapping("/{id}")
    public void update(@PathVariable("id") String id,@RequestBody @Valid TestDeviceVersionUpdDTO dto) {
        testDeviceVersionFeginClient.update(id, dto);
    }
    
    @ApiOperation("回显版本")
    @ApiOperationSupport(author = "瑶苏", order = 3)
    @GetMapping("/{id}")
    public TestDeviceVersionVO selectById(@PathVariable("id") String id) {
        return testDeviceVersionFeginClient.selectById(id);
    }
    
    @ApiOperation("提醒更新")
    @ApiOperationSupport(author = "瑶苏", order = 4)
    @PostMapping("/pubVersion")
    public void pubVersion(@RequestBody HardwareVersionReqDTO reqDto) {
        testDeviceVersionFeginClient.pubVersion(reqDto);
    }
    
    @ApiOperation("分页查询版本列表")
    @ApiOperationSupport(author = "瑶苏", order = 5)
    @GetMapping("/page")
    public Page<TestDeviceVersionSelVO> page(TestDeviceVersionQry qry) {
        return testDeviceVersionFeginClient.pageQuery(qry);
    }
    
    @ApiOperation("修改版本状态")
    @ApiOperationSupport(author = "瑶苏", order = 6)
    @PostMapping("/updateStatus")
    public void updateStatus(@RequestBody VersionStatusQry qry) {
        testDeviceVersionFeginClient.updateStatus(qry);
    }
    
}
